<?php

declare(strict_types=1);

namespace app\example\controller;

use app\admin\BaseAdminController;
use think\facade\View;

class Upload extends BaseAdminController
{
    public function index()
    {
        View::assign('title', 'dropzone插件/上传插件');
        return View::fetch();
    }

    public function web()
    {
        View::assign('title', 'webuploader插件/上传插件');
        View::assign('addJs', addJs(['webuploader', 'magnific-popup']));
        return View::fetch();
    }

    public function cropper()
    {
        View::assign('title', 'cropper图片裁剪/上传插件');
        View::assign('addJs', addJs(['cropper']));
        return View::fetch();
    }

    public function formdata()
    {
        View::assign('title', 'FormData上传/上传插件');
        return View::fetch();
    }

    public function attachment()
    {
        View::assign('title', 'webuploader(附件)/上传插件');
        View::assign('addJs', addJs(['webuploader']));
        return View::fetch();
    }

    public function image()
    {
        View::assign('title', 'webuploader(图片)/上传插件');
        View::assign('addJs', addJs(['webuploader']));
        return View::fetch();
    }

    public function upload_base64()
    {
        return json([
            'picurl' => './upload/images/lyear_6371ef6827655.jpg',
            'state' => 200,
        ]);
    }

    public function upload_data()
    {
        return json([
            'info' => '上传成功',
            'status' => 1,
            'url' => './upload/images/lyear_6371ef6827655.jpg',
        ]);
    }

    public function webuploader()
    {
        return json([
            'class' => 'bg-success success',
            'info' => '上传成功',
            'picurl' => './upload/images/lyear_6371ef6827655.jpg',
            'status' => 200,
        ]);
    }
}
